package com.suixun.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.authority.controller.BaseManager;
import com.suixun.service.RegionService;
import com.suixun.util.Constant;

@Controller
@RequestMapping("/region")
public class RegionManage extends BaseManager {

	@Resource
	private RegionService regionService;

	@ResponseBody
	@RequestMapping(value = "getRegions.json")
	public Object getRegions(String uuid) {
		try {
			return success(regionService.getRegions(uuid));
		} catch (Exception e) {
			e.printStackTrace();
			logger("RegionManage getRegions:" + e.getMessage(), e);
			return fail(Constant.EXCEPTION.OPERATE_FAIL);
		}
	}
	
	
	@ResponseBody
	@RequestMapping(value = "getPRegion.json")
	public Object getPRegion(String uuid) {
		try {
			return success(regionService.getPRegion(uuid));
		} catch (Exception e) {
			e.printStackTrace();
			logger("RegionManage getPRegion:" + e.getMessage(), e);
			return fail(Constant.EXCEPTION.OPERATE_FAIL);
		}
	}
	
	@ResponseBody
	@RequestMapping(value = "getAllPRegions.json")
	public Object getAllPRegions(String uuid) {
		try {
			return success(regionService.getAllPRegionsByUuid(uuid));
		} catch (Exception e) {
			e.printStackTrace();
			logger("RegionManage getAllPRegions:" + e.getMessage(), e);
			return fail(Constant.EXCEPTION.OPERATE_FAIL);
		}
	}
	
	@ResponseBody
	@RequestMapping(value = "getAllPUuids.json")
	public Object getAllPUuids(String province, String city, String town) {
		try {
			return success(regionService.getPUuidsByOrgName(province, city, town));
		} catch (Exception e) {
			e.printStackTrace();
			logger("RegionManage getAllPUuids:" + e.getMessage(), e);
			return fail(Constant.EXCEPTION.OPERATE_FAIL);
		}
	}
}
